﻿using System;
using System.Configuration;

namespace CodePlex.TfsPluginSuite.Configuration.BranchMergePolicy
{
    [ConfigurationCollection(typeof(SourcePathConfigurationElement), AddItemName = "SourcePath", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class BranchMergeConfigurationElement : ConfigurationElementCollection
    {
        [ConfigurationProperty("enabled", DefaultValue = (bool)false)]
        public bool Enabled
        {
            get
            {
                return (bool)base["enabled"];
            }
        }

        [ConfigurationProperty("matchTeamProjects", DefaultValue = (bool)false)]
        public bool MatchTeamProjects
        {
            get
            {
                return (bool)base["matchTeamProjects"];
            }
        }
        [ConfigurationProperty("setBranchSecurityToInheritOnly", DefaultValue = (bool)false)]
        public bool SetBranchSecurityToInheritOnly
        {
            get
            {
                return (bool)base["setBranchSecurityToInheritOnly"];
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new SourcePathConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            return ((SourcePathConfigurationElement)element).PathRegex;
        }
    }
}
